﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.Json;
using System.Threading.Tasks;

namespace LJ.StreamSystem.LazyHare.Internal;

public class StreamSystemMessageSerializer : IStreamSystemMessageSerializer
{
    private readonly static JsonSerializerOptions _jsonSerializerOptions = new(JsonSerializerDefaults.Web);

    public object Deserialize(string json, Type type)
    {
        return JsonSerializer.Deserialize(json, type, _jsonSerializerOptions)!;
    }

    public string Serialize(object value)
    {
        ArgumentNullException.ThrowIfNull(value, nameof(value));
        return JsonSerializer.Serialize(value, _jsonSerializerOptions);
    }
}
